home *** CD-ROM | disk | FTP | other *** search
- head 1.4;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.4
- date 88.09.22.22.14.13; author douglis; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.09.15.10.16.58; author douglis; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.09.13.16.44.15; author douglis; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.08.14.15.11.51; author douglis; state Exp;
- branches ;
- next ;
-
-
- desc
- @Get the last time someone logged in, from the login database.
- @
-
-
- 1.4
- log
- @return ptr to static buffer
- @
- text
- @/*
- * Ulog_LastLogin.c --
- *
- * Source code for the Ulog_LastLogin procedure.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: Ulog_LastLogin.c,v 1.3 88/09/15 10:16:58 douglis Exp $ SPRITE (Berkeley)";
- #endif not lint
-
-
- #include <ulog.h>
- #include "ulogInt.h"
-
-
- /*
- *----------------------------------------------------------------------
- *
- * Ulog_LastLogin --
- *
- * Retrieve information for the last login of the specified user.
- *
- * Results:
- * The user log data structure is returned if the retrieval is
- * successful. If there is no valid entry for the specified user,
- * or if an error occurs accessing the 'last log', NULL is returned.
- *
- * Side effects:
- * The 'last log' is opened, locked, and read before closing it again.
- *
- *----------------------------------------------------------------------
- */
-
-
- Ulog_Data *
- Ulog_LastLogin(uid)
- int uid;
- {
- static Ulog_Data data;
- char buffer[ULOG_RECORD_LENGTH];
- int status;
- int count;
-
- status = Db_ReadEntry(LASTLOG_FILE_NAME, buffer, uid, ULOG_RECORD_LENGTH,
- DB_LOCK_BREAK);
- if (status != 0) {
- return((Ulog_Data *) NULL);
- }
- if (buffer[0] == '\0') {
- errno = EACCES;
- return((Ulog_Data *) NULL);
- }
- /*
- * Try to parse the record. It's okay if the location field
- * doesn't match because it may be empty.
- */
- count = sscanf(buffer, ULOG_FORMAT_STRING, &data.uid,
- &data.hostID, &data.portID,
- &data.updated, data.location);
- if (count < ULOG_ITEM_COUNT - 1) {
- syslog(LOG_ERR, "Ulog_LastLogin: unable to parse record %d",
- uid);
- errno = EACCES;
- return((Ulog_Data *) NULL);
- } else if (count == ULOG_ITEM_COUNT - 1) {
- data.location[0] = '\0';
- }
- return(&data);
- }
-
-
-
-
-
-
-
- @
-
-
- 1.3
- log
- @allow an empty location field (since it's last in the record, this is
- okay).
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: Ulog_LastLogin.c,v 1.2 88/09/13 16:44:15 douglis Exp $ SPRITE (Berkeley)";
- d33 3
- a35 2
- * -1 indicates an error, in which case errno indicates more details.
- * 0 indicates success.
- d43 3
- a45 2
- int
- Ulog_LastLogin(uid, dataPtr)
- a46 1
- Ulog_Data *dataPtr;
- d48 1
- d53 2
- a54 2
- status = Db_ReadEntry(LASTLOG_FILE_NAME, uid, ULOG_RECORD_LENGTH,
- buffer, DB_LOCK_BREAK);
- d56 1
- a56 1
- return(-1);
- d60 1
- a60 1
- return(-1);
- d66 3
- a68 3
- count = sscanf(buffer, ULOG_FORMAT_STRING, &dataPtr->uid,
- &dataPtr->hostID, &dataPtr->portID,
- &dataPtr->updated, dataPtr->location);
- d73 1
- a73 1
- return(-1);
- d75 1
- a75 1
- dataPtr->location[0] = '\0';
- d77 1
- a77 1
- return(0);
- d79 4
- @
-
-
- 1.2
- log
- @changed to use ascii representation in database file.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: Ulog_LastLogin.c,v 1.1 88/08/14 15:11:51 douglis Exp $ SPRITE (Berkeley)";
- d54 1
- a54 1
- return(status);
- d56 8
- d67 1
- a67 1
- if (count != ULOG_ITEM_COUNT) {
- d72 2
- d77 3
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
- d47 1
- d49 1
- d51 15
- a65 3
- status = Db_ReadEntry(LASTLOG_FILE_NAME, uid, sizeof(Ulog_Data),
- (char *) dataPtr, DB_LOCK_BREAK);
- return(status);
- @
-